home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
19
/
madtrb40.zip
/
WINDMNGR.INC
< prev
next >
Wrap
Text File
|
1985-02-23
|
9KB
|
281 lines
{ Window Manager/Editor System Include file .. }
procedure set_page(page: byte);
type
Result =
record
AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: byte;
end;
var rec:result;
begin
Rec.AX := page;
Rec.BX := $05;
Intr($10,Rec);
end;
Procedure Scrn_off;
begin
inline($52/$50/$ba/$d8/$03/$b0/$21/$ee/$58/$5a)
end;
Procedure Scrn_on;
begin
inline($52/$50/$ba/$d8/$03/$b0/$29/$ee/$58/$5a)
end;
Function active: integer;
begin
active:=stack_top
end;
Procedure Push(Ulx, Uly, Lrx, Lry, Foreground, Background: integer);
{ This procedure Saves screens in memory. When a new window is put
on the Screen, the preceding window is stored away for later reference.}
begin
{ If last Window up, move the Original Screen into Screen Memory}
if stack_top = 0 then
begin
Scrn_off;
move(real_screen, Original, 4000);
Scrn_on
end;
{Save all Data concerning the windows}
if (Stack_top < MaxScreens) and (Stack_Top >= 0) then
begin
Stack_top:=Stack_top+1;
Imig[Stack_top].x1:=Ulx;
Imig[Stack_top].y1:=Uly;
Imig[Stack_top].x2:=Lrx;
Imig[Stack_top].y2:=Lry;
Imig[stack_top].c1:=Foreground;
Imig[Stack_top].b1:=Background
end;
{ Push Screen on Stack ... Sort of... }
Scrn_off;
Move(real_screen,Imig[Stack_top].Screen,4000);
Scrn_on
end;
Procedure Pop;
{ This Procedure takes the screen that procedes the current window and
Copies back to screen memory, restores all data concerning the previous
window and activates it.. Neat huh? }
begin
{ If no windows are active, save the current screen }
if stack_top =0 then
begin
normvideo;
window(1,1,80,25);
Scrn_off;
move(Original, real_screen, 4000);
Scrn_on;
end;
{ Get Preceding screen and copy it to screen memory }
Scrn_off;
Move(Imig[Stack_top].Screen,Real_Screen,4000);
Scrn_on;
Stack_top:=Stack_top-1
end;
Procedure Writexy(long_string:maxstr; xcoord,ycoord:integer; var color: integer);
{ This procedure Draws whatever you want, wherever you want, by changing the
value of Screen in the variable declaration, it can draw a "Picture" any-
were in memory. This allows for the Speed of the window making process..}
var str_len, real_pos, scr_pos: integer;
begin
{$I-}
str_len:=length(long_string); { So I know how much to write }
Scr_pos:=0;
{ The next 8 lines write the string in every "even" location in memory
and ever odd location gets the attribute with determines how the
string is displayed on the screen}
for real_pos:=1 to str_len do
if scr_pos < 4001 then
begin
scr_pos:=((xcoord*2)-1)+(ycoord*160);
screen[scr_pos]:=ord(copy(long_string,real_pos,1));
screen[scr_pos+1]:=color;
xcoord:=xcoord+1;
end
{$I+}
end;
Procedure Frame(WindowType, UpperLeftX, UpperLeftY, LowerRightX, LowerRightY, color: Integer);
{ This procedure draws the window frame in another part of memory. }
var i: integer;
begin
WriteXY(chr(Fc[WindowType,1]),UpperLeftX, UpperLeftY,color);
for i:=UpperLeftX+1 to LowerRightX-1 do WriteXY(chr(Fc[WindowType,2]),i,UpperleftY,color);
WriteXY(chr(Fc[WindowType,3]),i+1,UpperleftY,color);
for i:=UpperLeftY+1 to LowerRightY-1 do
begin
WriteXY(chr(Fc[WindowType,4]),UpperLeftX , i,color);
WriteXY(chr(Fc[WindowType,4]),LowerRightX, i,color);
end;
WriteXY(chr(Fc[WindowType,5]),UpperLeftX, LowerRightY, color);
for i:=UpperLeftX+1 to LowerRightX-1 do WriteXY(chr(Fc[WindowType,6]),i,LowerrightY,color);
WriteXY(chr(Fc[WindowType,7]),i+1,LowerRightY,color);
end { Frame };
Procedure initialize;
{ Set up memory and the stack }
var i:integer;
begin
Stack_top:=0;
move(real_screen,screen,4000);
with imig[1] do for i:=1 to 4000 do screen[i]:=$00;
for i:=2 to 9 do move(Imig[i-1].screen,imig[i].screen,4000);
move(imig[1].screen,screen,4000);
move(imig[1].screen,original,4000)
end;
Procedure Add_window(UpperLeftX,UpperLeftY,LowerRightX,LowerRightY,Foreground,
BackGround, WindowType: Integer);
{ This procedure does all the laborous work for you.. The variables make it
Fairly easy to understand. }
Var i,j,k,Color: Integer;
begin
Imig[Stack_top].w1:=whereX;
Imig[Stack_top].w2:=WhereY;
UpperLeftX:=UpperLeftX+1;
LowerRightX:=LowerRightX-1;
LowerRightY:=LowerRightY-2;
f1:=WindowType;color:=0;
Scrn_off;
move(real_screen,screen,4000);
Scrn_on;
{ Set color attribute for direct writeng to memory }
if background < 17 then Color:=foreground+(background*16);
{ Check for invalid window frame types }
if (WindowType > 5) or (WindowType < 0) then
begin
Clrscr;
Writeln('Invalid Frame Type!')
end
else
{ If the window is valid then Procede }
begin
{ Fill color Attribute of window directly into memory }
k:=1;
for j:=UpperLeftY to LowerRightY do
for i:=UpperLeftX to LowerRightX do
begin
k:=(j*160)+(i*2);
Screen[k]:=Color;
Screen[k-1]:=$20
end;
{ Frame Window }
Case Windowtype of
1:Frame(WindowType,UpperLeftX-1,UpperLeftY-1,
LowerRightX+1,LowerRightY+1,
color);
2:Frame(WindowType,UpperLeftX-1,UpperLeftY-1,
LowerRightX+1,LowerRightY+1,
color);
3:Frame(WindowType,UpperLeftX-1,UpperLeftY-1,
LowerRightX+1,LowerRightY+1,
color);
4:Frame(WindowType,UpperLeftX-1,UpperLeftY-1,
LowerRightX+1,LowerRightY+1,
color);
end { Case }
end;
{ Activate newly formed window }
Window(1,1,80,25);
Window(UpperLeftX,UpperLeftY+1,LowerRightX,LowerRightY+1);
push(UpperLeftx,UpperLeftY+1,LowerRightX,LowerRightY+1,Foreground, Background);
Scrn_off;
Move(screen,real_screen,4000);gotoxy(1,1);
Scrn_on;
Textcolor(Foreground);TextBackground(backGround);ClrScr;
end;
Procedure Color_window(Foreground, Background: integer);
{ This procedure allows you to change the foreground and background color
of the active window. }
var i,j,Color: Integer;
begin
{ Set Attribute value }
if background < 8 then Color:=foreground+(background*16);
{ Write new attribute direclty to screen memory }
for j:=(Imig[Stack_top].y1-2) to Imig[Stack_top].y2 do
for i:=(Imig[Stack_top].x1-1) to (Imig[Stack_top].x2+1) do
begin
Real_Screen[(j*160)+(i*2)]:=Color
end
end;
Procedure Remove(Num_to_Remove: Integer);
{ This Procedure removes 1 or a specified number of windows from the
screen and reactivates the underlying window }
var i: integer;
begin
if (Num_to_Remove > 0) and (Num_to_Remove < MaxScreens) then
for i:=1 to Num_to_remove do Pop
else
Pop;
Window(1,1,80,25);
Window(Imig[Stack_top].x1+1,Imig[Stack_top].y1,Imig[Stack_top].x2,Imig[Stack_top].y2);
gotoxy(1,1);
TextBackground(Imig[Stack_top].b1);TextColor(Imig[Stack_top].c1);
GotoXY((Imig[Stack_top].w1-1),Imig[Stack_top].w2)
end;
Procedure Window_Title(Name: Maxstr; color:integer);
var i, k, l, m: integer;
begin
If Length(name)>0 then
begin
l:=1;
color:=color+(Imig[Stack_top].b1*16);
if f1 < 4 then Real_Screen[(((Imig[Stack_top].Y1-2)*160)+(Imig[Stack_top].X1*2))+l]:=$5b;
for i:=1 to length(Name) do
begin
k:=(((Imig[Stack_top].Y1-2)*160)+(Imig[Stack_top].X1*2))+l+1;
Real_Screen[k+1]:=ord(copy(Name,i,1));
Real_Screen[k+2]:=color;
l:=l+2
end;
if f1 < 4 then Real_Screen[k+3]:=$5d
end
end;
{ Thats all.. }